// ----------------------------
// projects/darwin/TestDarwin.h
// Copyright (C) 2009
// Glenn P. Downing
// ----------------------------

#ifndef TestDarwin_h
#define TestDarwin_h

// --------
// includes
// --------

#include "cppunit/TestFixture.h"             // TestFixture
#include "cppunit/extensions/HelperMacros.h" // CPPUNIT_TEST, CPPUNIT_TEST_SUITE, CPPUNIT_TEST_SUITE_END

// ----------
// namespaces
// ----------

namespace cs {

// ----------
// TestDarwin
// ----------

struct TestDarwin : CppUnit::TestFixture {
    // -----
    // tests
    // -----

	void test_Coordinate(){
               Species hopper('h',Species::getHopperInstruction());
               Species rover('r',Species::getRoverInstruction());
               Species food('f',Species::getFoodInstruction());
               Species trap('t',Species::getTrapInstruction());
               Darwin d1(8,8);
               Creature h1(&hopper,0);
               Creature h2(&hopper,1);
               Creature h3(&hopper,2);
               Creature h4(&hopper,3);
               Creature f1(&food,1);
               Creature f2(&food,0);
               d1.setCreature(3,3,h1);
               d1.setCreature(3,4,h2);
               d1.setCreature(4,4,h3);
               d1.setCreature(4,3,h4);
               d1.setCreature(0,0,f1);
               d1.setCreature(7,7,f2);
               //testing functions inside Darwin
               Coordinate expectedC(3,3);
               CPPUNIT_ASSERT_EQUAL(expectedC.getX(),d1.getMyList(0).getX());
               CPPUNIT_ASSERT_EQUAL(expectedC.getY(),d1.getMyList(0).getY());




       }
       void test_Species(){
               Species hopper('h',Species::getHopperInstruction());
               Species rover('r',Species::getRoverInstruction());
               Species food('f',Species::getFoodInstruction());
               Species trap('t',Species::getTrapInstruction());
               Darwin d1(8,8);
               Creature h1(&hopper,0);
               Creature h2(&hopper,1);
               Creature h3(&hopper,2);
               Creature h4(&hopper,3);
               Creature f1(&food,1);
               Creature f2(&food,0);
               d1.setCreature(3,3,h1);
               d1.setCreature(3,4,h2);
               d1.setCreature(4,4,h3);
               d1.setCreature(4,3,h4);
               d1.setCreature(0,0,f1);
               d1.setCreature(7,7,f2);

               Species* expectedSpecies = d1.getCreature(3,3).getSpecies();
               CPPUNIT_ASSERT_EQUAL(expectedSpecies, &hopper);


       }
 
	void test_movement(){
               Species hopper('h',Species::getHopperInstruction());
               Species rover('r',Species::getRoverInstruction());
               Species food('f',Species::getFoodInstruction());
               Species trap('t',Species::getTrapInstruction());
               Darwin d1(8,8);
               Creature h1(&hopper,0);
               Creature h2(&hopper,1);
               Creature h3(&hopper,2);
               Creature h4(&hopper,3);
               Creature f1(&food,1);
               Creature f2(&food,0);

		h1.setDirection(1);
		CPPUNIT_ASSERT_EQUAL(h1.getDirection(),3);
		h1.setDirection(2);
		CPPUNIT_ASSERT_EQUAL(h1.getDirection(),0);
               d1.setCreature(3,3,h1);
               d1.setCreature(3,4,h2);
               d1.setCreature(4,4,h3);
               d1.setCreature(4,3,h4);
               d1.setCreature(0,0,f1);
               d1.setCreature(7,7,f2);
		Coordinate c(3,3);
		Coordinate c2(3,3);
		d1.hop(h1,c);
		CPPUNIT_ASSERT_EQUAL(c.getX(),d1.getNextSpot(h1.getDirection(),c2).getX());
		CPPUNIT_ASSERT_EQUAL(c.getY(),d1.getNextSpot(h1.getDirection(),c2).getY());
               //testing functions inside Darwin
              
       }
       


    // -----
    // suite
    // -----

    CPPUNIT_TEST_SUITE(TestDarwin);
    CPPUNIT_TEST(test_Species);
    CPPUNIT_TEST(test_Coordinate);
CPPUNIT_TEST(test_movement);

    CPPUNIT_TEST_SUITE_END();};

} // cs

#endif // TestDarwin_h

